﻿@model IEnumerable<PageViewModel>
@{
	ViewBag.Title = SiteStrings.AllPages_Title;
}
@if (RoadkillContext.IsAdmin)
{
	<script type="text/javascript">
		$(function () {
			Roadkill.Web.Setup.bindConfirmDelete();
		});
	</script>
}

<h1>@SiteStrings.AllPages_Title</h1>

@if (Model.Count() > 0)
{
	<table class="table table-striped">
		<thead>
			<tr>
				<th>@SiteStrings.AllPages_TitleColumnHeading</th>
				@if (RoadkillContext.IsLoggedIn)
				{
					<th></th>
					if (RoadkillContext.IsAdmin)
					{
					<th></th>
					}
				}
			</tr>
		</thead>
		@foreach (PageViewModel pageModel in Model)
		{
			<tr>
				<td class="pagename stretch">@Html.ActionLink(pageModel.Title, "Index", "Wiki", new { id = pageModel.Id, title = pageModel.EncodedTitle }, null)</td>
			@if (RoadkillContext.IsLoggedIn)
			{
				if (!pageModel.IsLocked || (pageModel.IsLocked && RoadkillContext.IsAdmin))
				{
				<td class="edit">@Html.ActionLink(SiteStrings.Shared_EditLink, "Edit", new { id = pageModel.Id }, new { @class = "btn btn-mini btn-primary" })</td>
				}
				if (RoadkillContext.IsAdmin)
				{
				<td class="delete">@Html.ActionLink(SiteStrings.Shared_DeleteLink, "Delete", new { id = pageModel.Id }, new { @class = "btn btn-mini btn-primary confirm" })</td>
				}
			}
			</tr>
		}
	</table>
}
else
{
	<p>@SiteStrings.AllPages_NoPages</p>
}